home *** CD-ROM | disk | FTP | other *** search
- package LockemUp;
-
- import com.siemens.mp.game.ExtendedImage;
- import com.siemens.mp.game.Melody;
- import com.siemens.mp.game.MelodyComposer;
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Font;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.List;
-
- public class TitleScreen extends BaseScreen {
- private static final int GAME_SCREEN_WIDTH = 96;
- private static final int GAME_SCREEN_HEIGHT = 80;
- private static final int DISAPPEAR_TIMER = 1;
- private static final String[] titles = new String[]{"res\\lock.bin", "res\\win.bin", "res\\lose.bin", "res\\help1.bin", "res\\help2.bin", "res\\help3.bin"};
- private int mode;
- private int timer;
- private int state;
- private boolean running;
- private boolean readyToPaint;
- private CommandListener listener;
- private byte[][] pixels = new byte[2][];
- private Image gameScreenImage;
- private ExtendedImage gameScreen;
- private boolean onSound;
- private Melody melody;
-
- public TitleScreen() {
- try {
- this.gameScreenImage = Image.createImage(96, 80);
- this.gameScreen = new ExtendedImage(this.gameScreenImage);
- this.pixels[0] = ((BaseScreen)this).ReadByteArray(titles[1], 960, 0);
- this.pixels[1] = ((BaseScreen)this).ReadByteArray(titles[2], 960, 0);
- byte[] var1 = ((BaseScreen)this).ReadByteArray(titles[0], 960, 0);
- this.gameScreen.setPixels(var1, 0, 0, 96, 80);
- } catch (Exception var3) {
- System.out.println("Exception: " + var3);
- }
-
- this.readyToPaint = true;
- this.timer = 1;
- this.mode = 100;
- this.state = 0;
- this.onSound = true;
- Object var4 = null;
- this.melody = this.createMelody(100);
- this.melody.play();
- }
-
- public void changeMode(int var1, String var2, String var3) {
- if (this.mode != 5) {
- this.mode = var1;
- if (this.mode < 2) {
- this.gameScreen.setPixels(this.pixels[var1], 0, 0, 96, 80);
- if (this.onSound) {
- this.melody = this.createMelody(var1);
- this.melody.play();
- }
-
- if (this.mode == 0) {
- Font var4 = Font.getFont(0, 1, 8);
- this.gameScreenImage.getGraphics().setFont(var4);
- this.gameScreenImage.getGraphics().drawString(var2, 51, 56, 20);
- this.gameScreenImage.getGraphics().drawString(var3, 51, 68, 20);
- }
- } else if (this.mode < 5) {
- byte[] var5 = ((BaseScreen)this).ReadByteArray(titles[this.mode + 1], 960, 0);
- this.gameScreen.setPixels(var5, 0, 0, 96, 80);
- Object var10 = null;
- } else {
- this.gameScreen.clear((byte)0);
- Font var9 = Font.getFont(0, 1, 8);
- this.gameScreenImage.getGraphics().setFont(var9);
- int var11 = var9.stringWidth("Saving best...");
- int var6 = var9.getHeight();
- int var7 = (96 - var11) / 2;
- int var8 = (80 - var6) / 2;
- this.gameScreenImage.getGraphics().drawString("Saving best...", var7, var8, 20);
- var7 -= 2;
- var8 -= 2;
- this.gameScreenImage.getGraphics().drawRect(var7, var8, var11 + 3, var6 + 3);
- var7 -= 2;
- var8 -= 2;
- this.gameScreenImage.getGraphics().drawRect(var7, var8, var11 + 7, var6 + 7);
- }
-
- this.gameScreen.blitToScreen(3, 0);
- this.readyToPaint = true;
- this.state = 0;
- }
- }
-
- public void setOnSound(boolean var1) {
- this.onSound = var1;
- }
-
- public void Dispose() {
- this.gameScreen = null;
- this.pixels = null;
- this.melody = null;
- }
-
- public void setStateValue(int var1) {
- this.state = var1;
- if (this.mode < 100) {
- this.gameScreen.clear((byte)0);
- }
-
- if (var1 < 4) {
- Font var6 = Font.getFont(0, 1, 8);
- this.gameScreenImage.getGraphics().setFont(var6);
- if (this.mode < 100) {
- int var2 = var6.stringWidth("Please wait...");
- int var3 = var6.getHeight();
- int var4 = (96 - var2) / 2;
- int var5 = (80 - var3) / 2;
- this.gameScreenImage.getGraphics().drawString("Please wait...", var4, var5, 20);
- var4 -= 2;
- var5 -= 2;
- this.gameScreenImage.getGraphics().drawRect(var4, var5, var2 + 3, var3 + 3);
- var4 -= 2;
- var5 -= 2;
- this.gameScreenImage.getGraphics().drawRect(var4, var5, var2 + 7, var3 + 7);
- }
- }
-
- this.gameScreen.blitToScreen(3, 0);
- }
-
- public int getReturnValue() {
- return this.state;
- }
-
- public void run() {
- this.running = true;
-
- while(this.running) {
- try {
- Thread.sleep(20L);
- ((Canvas)this).repaint();
- } catch (Exception var2) {
- System.out.println("Exception: " + var2);
- }
-
- if (this.state != 0) {
- this.running = false;
- } else if (this.mode > 99 && this.timer > 0) {
- --this.timer;
- if (this.timer <= 0) {
- this.setStateValue(1);
- }
- }
- }
-
- }
-
- public void paint(Graphics var1) {
- if (this.gameScreen != null && this.readyToPaint) {
- try {
- this.gameScreen.blitToScreen(3, 0);
- } catch (Exception var3) {
- System.out.println("Exception: " + var3);
- }
- }
-
- }
-
- protected void keyPressed(int var1) {
- if (var1 == -12) {
- this.listener.commandAction(List.SELECT_COMMAND, this);
- } else {
- if (this.mode > 99) {
- this.setStateValue(1);
- } else if (this.mode >= 2 && this.mode <= 4) {
- int var2 = ((Canvas)this).getGameAction(var1);
- switch (var2) {
- case 1:
- case 2:
- this.prevHelp();
- case 3:
- case 4:
- default:
- break;
- case 5:
- case 6:
- this.nextHelp();
- }
- }
-
- }
- }
-
- public void setCommandListener(CommandListener var1) {
- super.setCommandListener(var1);
- this.listener = var1;
- }
-
- public void nextHelp() {
- if (this.mode < 4) {
- this.changeMode(this.mode + 1, (String)null, (String)null);
- }
-
- }
-
- public void prevHelp() {
- if (this.mode > 2) {
- this.changeMode(this.mode - 1, (String)null, (String)null);
- }
-
- }
-
- private Melody createMelody(int var1) {
- try {
- MelodyComposer var2 = new MelodyComposer();
- var2.setBPM(132);
- switch (var1) {
- case 0:
- var2.appendNote(45, 5);
- var2.appendNote(52, 5);
- var2.appendNote(48, 5);
- var2.appendNote(40, 5);
- var2.appendNote(42, 5);
- var2.appendNote(49, 5);
- var2.appendNote(44, 5);
- var2.appendNote(51, 5);
- break;
- case 1:
- var2.appendNote(24, 5);
- var2.appendNote(19, 5);
- var2.appendNote(15, 5);
- var2.appendNote(14, 5);
- var2.appendNote(24, 5);
- var2.appendNote(19, 5);
- var2.appendNote(15, 5);
- var2.appendNote(14, 5);
- break;
- case 100:
- var2.appendNote(45, 5);
- var2.appendNote(52, 5);
- var2.appendNote(48, 5);
- var2.appendNote(40, 5);
- var2.appendNote(42, 5);
- var2.appendNote(49, 5);
- var2.appendNote(44, 5);
- var2.appendNote(51, 5);
- }
-
- return var2.getMelody();
- } catch (Exception var3) {
- System.out.println("Exception: " + var3);
- return null;
- }
- }
- }
-